package de.popforge.ui
{
	import flash.display.Sprite;

	public class SliderWithButtons extends Sprite
	{
		private var barSize: int;
		private var barStrength: int;
		public var slider: Slider;
		public var topCap:Sprite;
		public var botCap:Sprite;
		public var track:Sprite;
		
		
		public function SliderWithButtons( barSize: int, barStrength: int )
		{
			this.barSize = barSize;
			this.barStrength = barStrength;
			this.slider = new Slider( this.barSize - 33, this.barStrength, SliderAlign.VERTICAL );
			this.slider.y = 16;
			this.addChild(this.slider);
			
			this.track.height = this.barSize - 44;
			this.botCap.y = this.barSize - 27;
		}
		
		public function setKnobSize( size: Number ): void
		{
			if( size >= 1 )
			{
				topCap.visible = false;
				botCap.visible = false;
				track.visible = false;
				slider.visible = false;
			}
			else
			{
				topCap.visible = true;
				botCap.visible = true;
				track.visible = true;
				slider.visible = true;
			}
			
			this.slider.setKnobSize( size );
		}
		
		public function setBarSize( _barSize: Number, size:Number ): void
		{
			this.barSize = _barSize;
			this.track.height = this.barSize - 44;
			this.botCap.y = this.barSize - 27;
			
			this.slider.setBarSize( this.barSize - 33 );
			setKnobSize( size );
		}
	}
}